
/**
  ******************************************************************************
  * Copyright 2021 The Microbee Authors. All Rights Reserved.
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  * 
  * http://www.apache.org/licenses/LICENSE-2.0
  * 
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  * 
  * @file       support.h
  * @author     baiyang
  * @date       2023-4-23
  ******************************************************************************
  */

#pragma once

#ifdef __cplusplus
extern "C"{
#endif

/*----------------------------------include-----------------------------------*/
#include <stdint.h>

#include "hw_config.h"
/*-----------------------------------macro------------------------------------*/

/*----------------------------------typedef-----------------------------------*/

/*----------------------------------variable----------------------------------*/

/*-------------------------------------os-------------------------------------*/

/*----------------------------------function----------------------------------*/
extern void usb_cinit(void *pconfig);
extern void usb_cfini(void);
extern int usb_cin(void);
extern void usb_cout(uint8_t *buf, unsigned len);

void uart_cinit(void *config);
void uart_cfini(void);
int uart_cin(void);
void uart_cout(uint8_t *buf, unsigned len);

void led_init(void);
void led_on(unsigned led);
void led_off(unsigned led);
void led_toggle(unsigned led);

uint32_t get_mcu_id(void);
int get_mcu_desc(int max, uint8_t *revstr);
int check_silicon(void);

/* flash helpers from*/
extern void board_deinit(void);
extern void clock_deinit(void);
extern void arch_systic_deinit(void);
extern uint32_t flash_func_sector_size(unsigned sector);
extern void flash_func_erase_sector(unsigned sector);
extern void flash_func_write_word(uint32_t address, uint32_t word);
extern uint32_t flash_func_read_word(uint32_t address);
extern uint32_t flash_func_read_otp(uint32_t address);
extern uint32_t flash_func_read_sn(uint32_t address);
extern void arch_flash_lock(void);
extern void arch_flash_unlock(void);
extern void arch_setvtor(uint32_t address);
/*------------------------------------test------------------------------------*/

#ifdef __cplusplus
}
#endif



